import java.util.StringTokenizer;
import java.util.Vector;


public class Parser {

		/**
		 * Breaks the input string into words and removes punctuation.
		 * 
		 * @param text	The string to be parsed
		 * @return		A Vector of the words that compose the input string
		 */
		//Parse a text and return a list of word WITHOUT punctuation
	    public static Vector<String> parse(String text){
	        String separator = "!?.'(), \t\"/;:\n"; //LIST OF THE PUNCTIATION (probably not complete)

	        StringTokenizer st = new StringTokenizer( text, separator, true );
	        Vector<String> res = new Vector<String>();
	        
	        boolean notMarker = false;

	        while ( st.hasMoreTokens() ) {
	            String token = st.nextToken();
	            if ( token.length() == 1 && separator.indexOf( token.charAt( 0 ) ) >= 0 ) {
	            	//Uncomment if we want to add the punctuation in the list
	            /*	if(token.equals(" ") || token.equals("\t") || token.equals("\n")){}
	            	else
	            		res.add(token);
	            */
	            }
	            else if (notMarker)
	            	//this is used to remove the t alone after isn' or doesn' or don'
	            	notMarker = false;
	            else {
	            	if(token.equals("isn"))
	            	{
	            		res.add("isn't");
	            		notMarker = true;
	            	}
	            	else if(token.equals("doesn"))
	            	{
	            		res.add("doesn't");
	            		notMarker = true;
	            	}
	            	else if(token.equals("don"))
	            	{
	            		res.add("don't");
	            		notMarker = true;
	            	}
	            	else if(token.equals("aren"))
	            	{
	            		res.add("aren't");
	            		notMarker = true;
	            	}
	            	else
	            		res.add(token);
	            }

	        }
	        
	        return res;
	    }
}
